import WXAD from "../../../StartAb/WXAd";
import NativeCaller from "../NativeCaller";
import DailyTaskSystem from "../system/DailyTaskSystem";

const { ccclass, property } = cc._decorator;

@ccclass
export default class DailyTask extends cc.Component {

    @property(cc.Prefab)
    itemPrefab: cc.Prefab = null;

    @property(cc.Node)
    contentNode: cc.Node = null;

    protected start(): void {
        let taskList = DailyTaskSystem.taskList;
        for (let i = 0; i < taskList.length; ++i) {
            let node = cc.instantiate(this.itemPrefab);
            node.name = i.toString();
            node.parent = this.contentNode;
            node.active = true;
            node.x = 0;
            node.opacity = 255;
        }
    }

    protected onEnable(): void {
        let size = cc.view.getVisibleSize();
        if (size.height >= size.width * 2.2)
            WXAD.instance.showBanner();
    }

    protected onDisable(): void {
        WXAD.instance.hideBanner();
    }

}
